package com.zhudeshuai.zhudemolist.bean.realm_bean;

import com.google.gson.reflect.TypeToken;
import com.zhu.zhuCore.utils.GsonUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import io.realm.RealmModel;
import io.realm.annotations.Ignore;
import io.realm.annotations.RealmClass;

/**
 * @author zhudeshuai
 * @since 2018/10/11
 */
@RealmClass
public class Question implements RealmModel{
	private String questionDes;//问题描述
	@Ignore
	public Map<String, String> selectItems = new TreeMap<>();//选择项
	private String selectItemsDes;//选择项
	@Ignore
	public List<String> answerList = new ArrayList<>();//答案
	private String answerListDes;//答案

	private String answerStr;


	/**
	 * 存入数据库之前，对应数据
	 */
	public void preSave(){
		selectItemsDes = GsonUtils.toJson(selectItems);
		answerListDes = GsonUtils.toJson(answerList);
	}


	/**
	 * 获取数据之前，对应数据
	 */
	public void preGet(){
		selectItems = GsonUtils.fromJson(selectItemsDes, new TypeToken<TreeMap<String,String>>(){}.getType());
		answerList = GsonUtils.fromJson(answerListDes, new TypeToken<ArrayList<String>>(){}.getType());
	}

	public String getQuestionDes() {
		return questionDes;
	}

	public String getSelectItemsDes() {
		return selectItemsDes;
	}

	public String getAnswerListDes() {
		return answerListDes;
	}

	public String getAnswerStr() {
		return answerStr;
	}

	public void setQuestionDes(String questionDes) {
		this.questionDes = questionDes;
	}

	public void setSelectItemsDes(String selectItemsDes) {
		this.selectItemsDes = selectItemsDes;
	}

	public void setAnswerListDes(String answerListDes) {
		this.answerListDes = answerListDes;
	}

	public void setAnswerStr(String answerStr) {
		this.answerStr = answerStr;
	}
}
